#include "light_test.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

static int fd;

int light_init(void)
{
	//打开设备文件---/dev/light_drv
	fd = open("/dev/light_drv", O_RDWR); 
	if(fd < 0)
	{
		perror("open /dev/light_drv");
		return -1;	
	}

    //close(fd);
	return 0;
}

int read_light()
{
    int light_flag=-1;
    if(fd > 0)
    {
        //while(1)
        {
            int ret = read(fd,&light_flag,4);
            if (ret < 0)
            {
                perror("read /dev/key_drv error\n");
                return -1;
            }

            printf("light flag = %d\n",light_flag);
        }
    }

    return light_flag;
}
